package hacker_rank.ai;

import java.util.Scanner;

public class BotsSavePrincess {

	static void displayPathtoPrincess(int n, String[] grid) {
		int mx, my, px, py;
		mx = my = px = py = -1;
		
		int j = -1;

		for (int i = 0; i < n; i++) {
			j = grid[i].indexOf("m");
			if (j >= 0) {
				mx = i;
				my = j;
			}
			j = grid[i].indexOf("p");
			if (j >= 0) {
				px = i;
				py = j;
			}
		}

		for (int i = 0; i < px - mx; i++)
			System.out.println("DOWN");
		for (int i = 0; i < mx - px; i++)
			System.out.println("UP");
		for (int i = 0; i < my - py; i++)
			System.out.println("LEFT");
		for (int i = 0; i < py - my; i++)
			System.out.println("RIGHT");
		
		//System.out.printf("m:(%d, %d), p:(%d, %d)", mx, my, px, py);

	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int m;
		m = in.nextInt();
		String grid[] = new String[m];
		for (int i = 0; i < m; i++) {
			grid[i] = in.next();
		}

		displayPathtoPrincess(m, grid);
	}

}
